﻿using BCL.BaseLib;
using BCL.BaseLib.Basics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace BCL.WPFComponent.Base
{
    public abstract class BaseShowControl : System.Windows.Controls.UserControl, IShowControl
    {
        public FunctionControlSetting Setting { get ; set ; }
        public FunctionEntity Function { get; set; }
        public string Title { get; set; }

        public void Close()
        {
            System.Windows.Window.GetWindow(this).Close();
        }

        public abstract void LanguageBinding();

        public virtual void ReloadData(object data)
        {
           
        }

        public void Show()
        {
             CreateWindowsShow().Show();
        }

        public MessageBoxResult ShowDialog(IShowControl owner)
        {
             CreateWindowsShow().ShowDialog();
             return MessageBox;
        }


        private WindowsShow CreateWindowsShow()
        {
            WindowsShow windows = new WindowsShow(this);
            if (!string.IsNullOrEmpty(Title))
                windows.Title = Title;
            return windows;
        }

        private MessageBoxResult MessageBox = MessageBoxResult.None;
        public MessageBoxResult MessageBoxResult { get { return MessageBox; } set { MessageBox = value; } }
    }
}
